package com.ruoyi.market.utils;

import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;

import java.math.BigDecimal;

public class SysNumberUtil {

    public static BigDecimal getPointNumber(BigDecimal one, BigDecimal two, Integer scale){
        if (ObjectUtil.hasEmpty(one, two)){
            return BigDecimal.ZERO;
        }
        if (BigDecimal.ZERO.compareTo(one) == 0 || BigDecimal.ZERO.compareTo(two) == 0){
            return BigDecimal.ZERO;
        }
        return NumberUtil.div(one, two, 4).multiply(new BigDecimal(100));
    }

    public static BigDecimal getDiv(BigDecimal one, BigDecimal two, Integer scale){
        if (ObjectUtil.hasEmpty(one, two)){
            return BigDecimal.ZERO;
        }
        return NumberUtil.div(one, two, 4).multiply(new BigDecimal(100));
    }

}
